package com.mofang.ticketing.common.core.enums.merchant;

import com.mofang.ticketing.common.core.enums.EnumVO;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * 商户类型
 *
 * @author LGC
 */
@Getter
@AllArgsConstructor
public enum MerchantTypeEnum {
    /**
     * 商户类型
     */
    SCENIC(1, "景区"),
    ;
    private final Integer key;
    private final String value;

    public static String getValueByKey(int key) {
        Optional<MerchantTypeEnum> optional = Arrays.stream(MerchantTypeEnum.values())
                .filter(v -> v.getKey() == key).findAny();
        return optional.map(MerchantTypeEnum::getValue).orElse(null);
    }

    public static List<EnumVO> getKeyValueList() {
        return Arrays.stream(MerchantTypeEnum.values()).map(s ->
                new EnumVO(s.getKey(), s.getValue())).collect(Collectors.toList());
    }


}
